/**
 * Created by wty on 16/9/29.
 */
/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode(int x) { val = x; }
 * }
 */
public class MaxDepthOfBT {
    public int maxDepth(TreeNode root) {
        int left,right;
        if(root!=null){
            left=maxDepth(root.left);
            right=maxDepth(root.right);
            if(left>right) return 1+left;
            else return 1+right;
        }else return 0;
    }
}
